package pkg

import (
	"gitee.com/xuyiping_admin/pkg/xerr"
	"strings"
	"time"
)

const (
	Layout     = "2006-01-02 15:04:05"
	LayoutYear = "2006-01-02"
	LayoutTime = "15:04:05"
)

// UTCTimeToLoadTime Utc时间转换成东八区时间
func UTCTimeToLoadTime(utcTimeString string) (time.Time, error) {
	utcTime, err := time.Parse(time.RFC3339, utcTimeString)
	if err != nil {
		return time.Time{}, xerr.WithStack(err)
	}
	return utcTime, nil
}

// ContainsRune 返回字符串s中是否包含rune r，如果包含则返回r，否则返回rune(0)
func ContainsRune(s string, list []rune) rune {
	for _, r := range list {
		if strings.ContainsRune(s, r) {
			return r
		}
	}
	return rune(0)
}
